package answer.service.Impl;

import answer.mapper.AnswerMapper;
import answer.service.AnswerService;
import commons.pojo.Question;
import commons.vo.LivegoodsResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@Service
public class AnswerServiceImpl implements AnswerService {
    @Autowired
    private AnswerMapper answerMapper;
    @Override
    public LivegoodsResult answerSearch(int s) {
        Random random = new Random();
        int temp = random.nextInt(95)+1;
        ArrayList<Question> list = new ArrayList<>();
        for (int a = temp;a < temp + s;a++){
            Question question = answerMapper.selectById(a);
            list.add(question);
        }
        return LivegoodsResult.ok(list);
    }

    @Override
    public LivegoodsResult everyAnswer() {
        List<Question> questions = answerMapper.selectList(null);
        return LivegoodsResult.ok(questions);
    }


}
